#pragma once

#include <cmath>

namespace davmath { class vec2f; }
using namespace davmath;

/* * * * * * * * * *
 * vec2f
 * Author:	David Ogle
 * Date:	03/03/2012
 * 2D Vector of float values
 * * * * * * * * * */
class davmath::vec2f
{
private:
protected:
public:

	// Data union
	// Can access the vector components 
	// via array, or member notation
	union {
		float i[2];
		struct { float u, v; };
		struct { float x, y; };
	};



	// Constructors
	vec2f(void) { toZero(); }
	vec2f(const vec2f &src) {
		this->x		= src.x;
		this->y		= src.y;
	};
	vec2f(const float x, const float y) {
		this->x		= x;
		this->y		= y;
	};


	// Destructor
	~vec2f(void) { };



	void			toZero();									// zero vector
	vec2f			inverse()						const;		// inverse
	float			lengthSquared()					const;		// length-squared
	float			length()						const;		// length. Vector magnitude

	static vec2f	dot(const vec2f &a, const vec2f &b);		// dot product

	inline vec2f	operator-()	const;							// inverse
	inline bool		operator==(const vec2f &src)	const;		// equals
	inline bool		operator!=(const vec2f &src)	const;		// not-equals
	inline vec2f	operator-(const vec2f &src)		const;		// vector subtraction
	inline vec2f	operator+(const vec2f &src)		const;		// vector addition
	inline vec2f	operator*(const vec2f &src)		const;		// vector multiplication
	inline vec2f	operator/(const vec2f &src)		const;		// vector division
	inline void		operator+=(const vec2f &src);				// add-equals
	inline void		operator-=(const vec2f &src);				// subtract-equals
	inline void		operator*=(const vec2f &src);				// multiply-equals
	inline void		operator/=(const vec2f &src);				// divide-equals

	inline vec2f	operator+(const float a)		const;		// scalar addition
	inline vec2f	operator-(const float a)		const;		// scalar subtraction
	inline vec2f	operator*(const float a)		const;		// scalar multiply
	inline vec2f	operator/(const float a)		const;		// scalar divide

};

